package GUIs;

import BaseDeDatos.ManejadorBD;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import javax.swing.JButton;

/**
 *
 * @author Tinacho
 */
public class GUI_ModificarCorredor extends javax.swing.JFrame {
    
    private Connection conexion = null;

    public GUI_ModificarCorredor() {
        initComponents();
        centrarJFrame();
    }

    
    // ---------------------------------------------------------
    // ------- Seccion de metodos publicos : Getters
    // ---------------------------------------------------------
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_DNI'
     */
    public String obtenerJTF_DNI() {
        return this.jText_DNI.getText();
    }// Fin obtenerJTF_DNI
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Nombre'
     */
    public String obtenerJTF_Nombre() {
        return this.jText_Nombre.getText();
    }// Fin obtenerJTF_Nombre
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Apellido'
     */
    public String obtenerJTF_Apellido() {
        return this.jText_Apellido.getText();
    }// Fin obtenerJTF_Apellido    
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Edad'
     */
    public int obtenerJTF_Edad() {
        int edad;
        if(this.jText_Edad.getText().compareTo("") == 0){
            edad = 25;
        }
        else{
            edad = Integer.parseInt(this.jText_Edad.getText());
        }
        return edad;
    }// Fin obtenerJTF_Edad  
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Domicilio'
     */
    public String obtenerJTF_Domicilio() {
        return this.jText_Domicilio.getText();
    }// Fin obtenerJTF_Domicilio    
    
    /**
     * 
     * @return el valor corriente de la variable 'jText_Telefono'
     */
    public String obtenerJTF_Telefono() {
        return this.jText_Telefono.getText();
    }// Fin obtenerJTF_Telefono
    
    /**
     * 
     * @return el valor corriente de la variable 'jCB_Categoria'
     */
    public String obtenerJCB_Categoria() {
        return this.jCB_Categoria.getSelectedItem().toString();
    }// Fin obtenerJCB_Categoria
    
    /**
     * 
     * @return el valor corriente de la variable 'jbutton_Guardar'
     */
    public JButton obtenerJB_Guardar() {
        return this.jbutton_Guardar;
    }// Fin obtenerJB_Guardar    
    
    
    public void rellenarCampoDNI(String dni){
        this.jText_DNI.setText(dni);
    }
    
    
    public void rellenarCampoNombre(String nombre){
        this.jText_Nombre.setText(nombre);
    }
    
    
    public void rellenarCampoApellido(String apellido){
        this.jText_Apellido.setText(apellido);
    }
    
    
    public void rellenarCampoEdad(String edad){
        this.jText_Edad.setText(edad);
    }
    
    
    public void rellenarCampoDomicilio(String domicilio){
        this.jText_Domicilio.setText(domicilio);
    }
    
    
    public void rellenarCampoTelefono(String telefono){
        this.jText_Telefono.setText(telefono);
    }
    
    
    public void rellenarComboBoxCategoria(String categoria){
        int index = 0;
        if(categoria.compareTo("B") == 0){
            index = 1;
        }
        else{
            if(categoria.compareTo("C") == 0){
                index = 2;
            }
            else{
                if(categoria.compareTo("D") == 0){
                    index = 3;
                }
            }
        }
        this.jCB_Categoria.setSelectedIndex(index);
    }
    
    
    
    /**
     * Metodo encargado de asociar los eventos correspondientes a 
     * los diferentes componentes de la interfaz
     * 
     * @param lis
     */
    public void setActionListeners(ActionListener lis) {
        this.jbutton_Guardar.addActionListener(lis);   
    }// Fin setActionListeners    
    
    

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label_titulo = new javax.swing.JLabel();
        label_dni = new javax.swing.JLabel();
        jText_DNI = new javax.swing.JTextField();
        label_Nombre1 = new javax.swing.JLabel();
        jText_Nombre = new javax.swing.JTextField();
        label_Apellido = new javax.swing.JLabel();
        jText_Apellido = new javax.swing.JTextField();
        label_Edad = new javax.swing.JLabel();
        jText_Edad = new javax.swing.JTextField();
        label_Domicilio = new javax.swing.JLabel();
        jText_Domicilio = new javax.swing.JTextField();
        label_Telefono = new javax.swing.JLabel();
        jText_Telefono = new javax.swing.JTextField();
        label_Categoria = new javax.swing.JLabel();
        jCB_Categoria = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jbutton_Guardar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Modificar Corredor");
        setAlwaysOnTop(true);

        label_titulo.setFont(new java.awt.Font("Andalus", 0, 18)); // NOI18N
        label_titulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_titulo.setText("Por favor, introduzca la información a actualizar del corredor");

        label_dni.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_dni.setText("DNI (*)");

        jText_DNI.setEditable(false);

        label_Nombre1.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Nombre1.setText("Nombre (*)");

        label_Apellido.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Apellido.setText("Apellido (*)");

        label_Edad.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Edad.setText("Edad");

        label_Domicilio.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Domicilio.setText("Domicilio");

        label_Telefono.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Telefono.setText("Teléfono");

        label_Categoria.setFont(new java.awt.Font("Andalus", 2, 14)); // NOI18N
        label_Categoria.setText("Categoría");

        jCB_Categoria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A", "B", "C", "D" }));

        jLabel1.setText("(*) Campos obligatorios");

        jbutton_Guardar.setText("Guardar Información");
        jbutton_Guardar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jText_Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, 484, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_Domicilio, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jText_Domicilio, javax.swing.GroupLayout.PREFERRED_SIZE, 484, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jText_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, 484, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_titulo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_dni, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jText_DNI, javax.swing.GroupLayout.PREFERRED_SIZE, 474, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_Nombre1, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jText_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 474, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(label_Edad, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, Short.MAX_VALUE)
                                .addComponent(jText_Edad, javax.swing.GroupLayout.PREFERRED_SIZE, 474, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel1))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jbutton_Guardar)
                        .addGap(224, 224, 224))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(label_Categoria, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jCB_Categoria, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jText_Apellido, jText_DNI, jText_Domicilio, jText_Edad, jText_Nombre, jText_Telefono});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_titulo)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_dni)
                    .addComponent(jText_DNI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Nombre1)
                    .addComponent(jText_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Apellido)
                    .addComponent(jText_Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Edad)
                    .addComponent(jText_Edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Domicilio)
                    .addComponent(jText_Domicilio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Telefono)
                    .addComponent(jText_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_Categoria)
                    .addComponent(jCB_Categoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbutton_Guardar)
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jText_Apellido, jText_DNI, jText_Domicilio, jText_Edad, jText_Nombre, jText_Telefono});

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUI_ModificarCorredor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUI_ModificarCorredor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUI_ModificarCorredor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI_ModificarCorredor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GUI_ModificarCorredor().setVisible(true);
            }
        });
    }

    private void centrarJFrame(){
        Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frame =this.getSize();
        this.setLocation((pantalla.width-frame.width)/2, (pantalla.height-frame.height)/2);
    }    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jCB_Categoria;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField jText_Apellido;
    private javax.swing.JTextField jText_DNI;
    private javax.swing.JTextField jText_Domicilio;
    private javax.swing.JTextField jText_Edad;
    private javax.swing.JTextField jText_Nombre;
    private javax.swing.JTextField jText_Telefono;
    private javax.swing.JButton jbutton_Guardar;
    private javax.swing.JLabel label_Apellido;
    private javax.swing.JLabel label_Categoria;
    private javax.swing.JLabel label_Domicilio;
    private javax.swing.JLabel label_Edad;
    private javax.swing.JLabel label_Nombre1;
    private javax.swing.JLabel label_Telefono;
    private javax.swing.JLabel label_dni;
    private javax.swing.JLabel label_titulo;
    // End of variables declaration//GEN-END:variables
}
